package com.curluin.model;

import android.util.Log;

import com.curluin.approximateShapes.ApproximateShape;
import com.curluin.approximateShapes.Contour;
import com.curluin.approximateShapes.Ellipse;
import com.curluin.controll.Controller;
import com.curluin.math.MyVector;
import com.curluin.scene.Cube;
import com.curluin.scene.Node;
import com.curluin.scene.TriangleMesh;

public class Fishbone extends Moveable implements Obstacle{

	public Fishbone(MyVector position, int positionMode){
		super(position, MyVector.makeVector3(0, 0, 0), ModelObject.CONSITENCY_HARD_AS_ICE);
		debugColor=TriangleMesh.BROWN;
		if(this.getClass().equals(Fishbone.class)) initialize(position,positionMode);
	}

	public Fishbone(TriangleMesh fishmesh, MyVector position, int positionMode, MyVector rotation) {
		super(fishmesh,position, MyVector.makeVector3(0, 0, 0), ModelObject.CONSITENCY_HARD_AS_ICE);
		debugColor=TriangleMesh.BROWN;
		if(this.getClass().equals(Fishbone.class)){
			initialize(position,positionMode);
			node.rotate(rotation, false);
			this.shape.rotateScanData(node.xyzRotationAngles, node.getCenter());
		}

	}

	@Override
	protected Node composeGraphics() {
		return new Cube(MyVector.makeVector3(0, 0, 0), 10, 3, 5, TriangleMesh.BROWN);
	}

	@Override
	protected ApproximateShape initializeApproximateShape() {
		//		Rectangle r = new Rectangle( node);
		Contour r = new Contour(6 ,node);
//				Ellipse r = new Ellipse(node);
		r.scan(Controller.getGridFieldWidth(),true);
		return r;
	}


	@Override
	public MyVector detailledCollisionCheck(ModelObject mo) {
		// TODO Implement detailled collision check
		if(mo.equals(this)) return null;
		if(mo.position.get(1)-mo.getSize().get(1)/2>this.position.get(1)+node.outerSize.get(1)/2) return null;
		if(mo.position.get(1)+mo.getSize().get(1)/2<this.position.get(1)-node.outerSize.get(1)/2) return null;
		return this.position;
	}



}
